package com.wuxiaofan.listener;

import com.wuxiaofan.event.LogEvent;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class LogListener implements ApplicationListener<LogEvent> {


    @SneakyThrows
    @Override
    public void onApplicationEvent(LogEvent event) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        String id = event.getId();
        String msg = event.getMsg();
        String logType = event.getLogType();

        log.info("id:{},msg:{},logType:{}",id,msg,logType);
        throw new RuntimeException("运行异常");
    }
}
